package com.gitee.linmt.entity;

import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Set;

/**
 * 用户信息.
 *
 * @author <a href="mailto:lin-mt@outlook.com">lin-mt</a>
 */
public class UserInfo implements UserDetails, CredentialsContainer {
    
    private static final long serialVersionUID = -7659356672302423630L;
    
    private Long id;
    
    private String username;
    
    private String password;
    
    private boolean accountNonExpired = true;
    
    private boolean accountNonLocked = true;
    
    private boolean credentialsNonExpired = true;
    
    private boolean enabled = true;
    
    private Set<? extends GrantedAuthority> authorities;
    
    private Set<Location> locations;
    
    public Long getId() {
        return id;
    }
    
    public void setId(final Long id) {
        this.id = id;
    }
    
    @Override
    public String getUsername() {
        return username;
    }
    
    public void setUsername(final String username) {
        this.username = username;
    }
    
    @Override
    public String getPassword() {
        return password;
    }
    
    public void setPassword(final String password) {
        this.password = password;
    }
    
    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }
    
    public void setAccountNonExpired(final boolean accountNonExpired) {
        this.accountNonExpired = accountNonExpired;
    }
    
    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }
    
    public void setAccountNonLocked(final boolean accountNonLocked) {
        this.accountNonLocked = accountNonLocked;
    }
    
    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }
    
    public void setCredentialsNonExpired(final boolean credentialsNonExpired) {
        this.credentialsNonExpired = credentialsNonExpired;
    }
    
    @Override
    public boolean isEnabled() {
        return enabled;
    }
    
    public void setEnabled(final boolean enabled) {
        this.enabled = enabled;
    }
    
    @Override
    public Set<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }
    
    public void setAuthorities(final Set<? extends GrantedAuthority> authorities) {
        this.authorities = authorities;
    }
    
    public Set<Location> getLocations() {
        return locations;
    }
    
    public void setLocations(final Set<Location> locations) {
        this.locations = locations;
    }
    
    @Override
    public void eraseCredentials() {
        this.password = null;
    }
}
